package com.cetccloud.ap.proxy.coord;

import com.cetccloud.ap.proxy.common.ProxyContext;
import com.cetccloud.ap.proxy.common.event.CallbackEvent;
import com.cetccloud.ap.util.Constants;
import com.cetccloud.ap.util.exception.ApException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import reactor.core.publisher.MonoSink;

/**
 * @ClassName SrcCoord
 * @Description TODO
 * @Author superz
 * @Date 2021/4/11 10:29
 * @Version 1.0
 **/
@Slf4j
@Component("srcCoord")
public class SrcCoord extends AbstractCoord {

    @Override
    protected String cacheName() {
        return Constants.COORD_SRC_CACHE;
    }

    @Override
    protected String eventbusAddress() {
        return "coord.src";
    }

    @Override
    protected void dealCallback(CallbackEvent event, MonoSink sink, ProxyContext context) {
        if (event.isSuccess()) {
            sink.success(event.getData());
        } else {
            sink.error(new ApException(event.getMessage()));
        }
    }

}
